﻿using System.Data.Entity;

using System.Collections.Generic;

using System.Linq;
using System.Data.Entity.Infrastructure;
using SIG.Model;
using SIG.Data;
using SIG.Data.UnitOfWork;
using SIG.Infrastructure.Cache;
using System;

namespace SIG.Repository
{
    public class PageRepository : Repository<Page>, IPageRepository
    {
        IMainBCUnitOfWork _unitOfWork;
        private ICacheService _cacheService;
        public PageRepository(IMainBCUnitOfWork unitOfWork, ICacheService cacheService) : base(unitOfWork) {

            if (unitOfWork == (IMainBCUnitOfWork)null)
                throw new ArgumentNullException("unitOfWork");
            if (cacheService == (ICacheService)null)
                throw new ArgumentNullException("cacheService");
            this._unitOfWork = unitOfWork;
            this._cacheService = cacheService;
        }



        //public int SearchPagesCount(string Title)
        //{
        //    var pages = _dbset.AsQueryable();

        //    if (!string.IsNullOrEmpty(Title))
        //    {
        //        pages = pages.Where(p => p.Title.Contains(Title));
        //    }

        //    var result = pages.Count();

        //    return result;
        //}

        //public IList<Page> SearchPages(int pageIndex, int pageSize, string Title)
        //{
        //    var pages = _dbset.AsQueryable();

        //    if (!string.IsNullOrEmpty(Title))
        //    {
        //        pages = pages.Where(p => p.Title.Contains(Title));
        //    }

        //    var result = pages
        //        .OrderByDescending(l => l.CreatedDate)
        //        .Skip(pageIndex * pageSize).Take(pageSize).ToList();

        //    return result;
        //}

        //public int ActivePagesCount()
        //{
        //    var pages = this.GetAll().Where(p=>p.Active).AsQueryable();          

        //    var result = pages.Count();
        //    return result;
        //}

        //public IList<Page> GetActivePages(int pageIndex, int pageSize)
        //{
        //    var pages = this.GetAll().Where(p=>p.Active).AsQueryable();        

        //    var result = pages
        //        .OrderByDescending(l => l.CreatedDate)
        //        .Skip(pageIndex * pageSize).Take(pageSize).ToList();

        //    return result;
        //}

    }
}
